Installer Tutorial

This is a quick guide on how to create scripts for the Installer utility. If you are producing anything which requires an installer, you should use this utility rather than an AmigaDOS script or a self-coded attempt; not only does it keep a standard approach for users, but it is a powerful program.

Of course, many are put off by its apparent complexity, but don't! The best advice is to get hold of installer scripts, and look at them in a text editor. Maybe use one as the basis for your script, editing it where necessary.

For this tutorial, we will look at the Installer for the Full version of DoubleClick Issue 4 (how appropriate). This is under the filename 'Install_DC4.txt', and you can view it here if you wish with multiview. Please note that I have added '.txt' so that this mag can load it as a text file - it is usual to have no extensions for scripts!

Let's have a look at it. The semicolons are for comments like in a DOS script - the rest of the line ignored. All the commands are placed in brackets, ie, ( command ), but you can also nest commands, eg, ( command (another command) ). The command (complete 0) sets the pecentage value displayed - put this at various places in your script with appropriate percentage values. Next we have the set command. This takes the form:
(set variable value)
Where the variable is given the value specified. In the script, we have the variable DC4-dest, which will hold the directory location to install to, but you will see the is a whole load more stuff than the simple for I gave. Don't worry, it isn't too complex - remember what I said about nested commands. The askdir command displays a directory listing, and gets the user to select a drawer, and then returns the selected directory as the value to be stored as DC4-dest. askdir takes certain parameters; prompt is the message displayed, and help is what is displayed if the user selects 'Help'. \n just means start a new line.

Then another set command, and here we see the tackon command:
(tackon variable bit-to-add-on)
Basically, it adds the bit onto the specified variable. Here, we add a drawer name onto the selected drawer, as we are following the convention of installing into a newly created drawer inside the selected drawer.

And then we create that drawer with makedir. (infos) means that the drawer will have an icon.

After a few more drawers are created (with the help of tackon), we get to the file copying with the copyfiles command. As well as setting a prompt and help listing (which we set to the default by using @copyfiles-help), we set the source and destination with the parameters source and dest. We can filter out files with pattern. Here, we say all files by specifying "#?", but later we copy individual files (eg, "Issue4"). (infos) this time means that '.info' files are copied.

You will see that for some of the files, there is an if command. When copying files to Libs: and C:, we don't want to overwrite what might be a newer version, so we only copy if the file doesn't exist (NB: Even better, you could check the version of the currently installed file, but I'm not sure on how to do that yet!) The format for if is:
(if (test) (commands to carry out if test is true) )
test takes the form operator variable1 variable2, eg, = a b would test if a was equal to b. Or <> c d would test if c was not equal to d. Easy! Note that you can also have an else clause, ie, a set of commands to follow if the condition isn't satisfied:
(if (test) (commands if true) (commands if false) )

Well, that's about it for this script, except for (exit) - guess what that does!

To get your script working from Workbench, give it a Project icon, and set the default tool to Installer. There are various tooltypes, again, just look at the Install_DC4 script, and other scripts, to see what can be done. In particular, you can set the minimum and default installer level (ie, Novice, Intermediate, Expert), as well as setting the application name.

Oh yes, a piece of advice. If you are having problems in running the script, then make sure your brackets match up, ie, you have one ) for every (, as that seemed to be the biggest problem for me!

Have fun!

Mark